/*
 * @Date: 2022-04-06 11:16:10
 * @LastEditors: sailornpg
 * @LastEditTime: 2022-04-23 16:27:12
 * @FilePath: \weibovue\src\api\user.ts
 * @Description: 用户api
 */

import { UserData } from "./types";
import { request } from "../utils/request";
//注册接口
export const reqRegister = (data: UserData) => {
  return request({
    url: "/users/register",
    method: "post",
    data,
  });
};
//登陆接口
export const reqLogin = (data: UserData) => {
  return request({
    url: "/users/login",
    method: "post",
    data,
  });
};
//获取登陆后的用户信息
export const reqUserInfo = () => {
  return request({
    url: "/users",
    method: "get",
  });
};
//获取其他的用户信息
export const reqOtherUserInfo = (id: number) => {
  return request({
    url: `/users/${id}`,
    method: "get",
  });
};
//更新用户信息
export const reqUpdateUserInfo = (id: number, data: UserData) => {
  return request({
    url: `/users/${id}`,
    method: "patch",
    data,
  });
};
//退出登陆
export const reqLogOut = () => {
  return request({
    url: `/users/logout`,
    method: "post",
  });
};
//关注
export const reqFollowUser = (id: number) => {
  return request({
    url: `/users/follow/${id}`,
    method: "put",
  });
};
//取消关注
export const reqUnFollowUser = (id: number) => {
  return request({
    url: `/users/follow/${id}`,
    method: "delete",
  });
};
//获取粉丝列表
export const reqFollowUserList = (id: number) => {
  return request({
    url: `/users/follower/${id}`,
    method: "get",
  });
};
//获取关注列表
export const reqFollowingList = (id: number) => {
  return request({
    url: `/users/following/${id}`,
    method: "get",
  });
};
//获取@我的的数量
export const reqAtMeCount = () => {
  return request({
    url: `/users/atMe`,
    method: "get",
  });
};
//获取@我的评论列表
export const reqAtMeReplyList = (currentPage: number = 1) => {
  return request({
    url: `/users/atMeReplyList?currentPage=${currentPage}`,
    method: "get",
  });
};
//获取@我的博客列表
export const reqAtMeBlogList = (currentPage: number = 1) => {
  return request({
    url: `/users/atMeBlogList?currentPage=${currentPage}`,
    method: "get",
  });
};
//已读回复
export const readReply = (
  blogId: number = -1,
  ReplyId: number = -1,
  commentId: number = -1,
) => {
  return request({
    url: `/users/read/${blogId}/${ReplyId}/${commentId}`,
    method: "post",
  });
};
//已读博客@
export const readBlog = (blogId?: number) => {
  return request({
    url: `/users/readblog/${blogId}`,
    method: "put",
  });
};
//点赞博客
export const reqLikeBlog = (blogId?: number) => {
  return request({
    url: `/users/like/${blogId}`,
    method: "put",
  });
};
//取消点赞
export const reqUnLikeBlog = (blogId?: number) => {
  return request({
    url: `/users/unLike/${blogId}`,
    method: "delete",
  });
};
